package com.terrynoya.fight.stateMachine.triggers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.combat.ProjectileInfo;
	import com.terrynoya.fight.emuns.ProjectileDataType;
	import com.terrynoya.fight.evaluation.Node;
	import com.terrynoya.fight.evaluation.ParseState;

	public class ProjHitTime
	{
		public function ProjHitTime()
		{
		}
		
		public static function eval(data:Object,node:Node):*
		{
			var chara:Character = Character(data);
			if(chara == null)
			{
				return 0;
			}
			var projecTileId:int = node.getChildAt(0).excute(data);
			var projInfo:ProjectileInfo = chara.offensiveInfo.projecTileInfo;
			if(projInfo.dataType == ProjectileDataType.Hit 
				&& (projecTileId <= 0 || projecTileId == projInfo.projecTileId)
			)
			{
				return projInfo.time;	
			}
			
			return -1;
		}
		
		public static function parse(state:ParseState):Node
		{
			return state.buildParenNumberNode(true);
		}
	}
}